package unimelb.distSystems.game.elements;

import com.jme3.asset.AssetManager;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.collision.shapes.BoxCollisionShape;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.material.Material;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;

public class Track {
	
	Material mat3;
	
	public void setup(AssetManager assetManager, Node rootNode, BulletAppState bulletAppState)
	{
	      Box floorBox = new Box(Vector3f.ZERO, 50f, 0.1f, 50f);
	      floorBox.scaleTextureCoordinates(new Vector2f(3, 6));

	      Geometry floor = new Geometry("floor", floorBox);
	      
	      Material mat3 = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
	      
		  floor.setMaterial(mat3);
//	      floor.setShadowMode(ShadowMode.Receive);
	      floor.setLocalTranslation(0, -0.1f, 0);
	      
	      floor.addControl(new RigidBodyControl(new BoxCollisionShape(new Vector3f(50f, 0.1f, 50f)), 0));
	      
	      Spatial test_track = assetManager.loadModel("Models/track2.mesh.xml");
	      rootNode.attachChild(test_track);
	      //rootNode.attachChild(floor);
	      bulletAppState.getPhysicsSpace().add(test_track);
	      //bulletAppState.getPhysicsSpace().add(floor);
	}

}
